#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>

#define MCAST_PORT 8888
#define MCAST_ADDR  "224.0.0.0.88"
#define MCAST_DATA "BROADCAST TEST DATA"
#define MCAST_INTERVAL 5

int main()
{
    int s ;
    struct sockaddr_in mcast_addr;
    s = socket(AF_INET , SOCK_DGRAM , 0);
    if(s == -1)
    {
        perror("socket()");
        return -1;
    }

    memset(&mcast_addr, 0 ,sizeof(mcast_addr));
    mcast_addr.sin_family = AF_INET;
    mcast_addr.sin_addr.s_addr = inet_addr(MCAST_ADDR);
    while(1)
    {
        int n = sendto(s , MCAST_DATA ,sizeof(MCAST_DATA) , (struct sockaddr *)&mcast_addr , sizeof(mcast_addr));
        if(n < 0 )
        {
            perror(" send to ()");
            return -2;
        }

        sleep(4);
    }
}
